//
//  DHHeaderCell.m
//  精品酒店
//
//  Created by DIANGHONG on 2018/5/9.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "DHHeaderCell.h"
#import <SDWebImage/SDImageCache.h>
@interface DHHeaderCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconView; // 头像
@property (weak, nonatomic) IBOutlet UILabel *nameLabel; // 名称
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel; // 手机号码
@property (weak, nonatomic) IBOutlet UIButton *notAuthButton; // 未认证按钮
@property (weak, nonatomic) IBOutlet UIButton *monthlyPay; // 本月收入按钮
@property (weak, nonatomic) IBOutlet UIButton *userComment; // 用户评价按钮
@property (weak, nonatomic) IBOutlet UIButton *monthlyOrderButton; // 本月订单按钮
@property (weak, nonatomic) IBOutlet UIView *userInfoCardView;

@end
@implementation DHHeaderCell

- (void)setModel:(DHMemberInfoModel *)model{
    _model = model;
    self.iconView.image = nil;

    
    [[SDImageCache sharedImageCache] clearMemory];
    [[SDImageCache sharedImageCache]clearDiskOnCompletion:nil];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.avator]];
    self.phoneLabel.text = model.member_mobile;
    self.nameLabel.text = model.user_name;
}
#pragma mark: - tag 0 本月接单/tag 1 本月收入/ tag 2用户评价 按钮监听
- (IBAction)mothlyButtonClick:(UIButton *)sender
{
    [self.delegate headerCell:self selectedMothlyButtonTag:sender.tag];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.iconView.layer.masksToBounds = true;
    self.iconView.layer.cornerRadius = 30;
    self.userInfoCardView.layer.masksToBounds = true;
    self.userInfoCardView.layer.cornerRadius = 10;
    
    // 头像手势添加
    self.iconView.userInteractionEnabled = true;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeIcon:)];
    [self.iconView addGestureRecognizer:tap];
}
#pragma mark: - 头像点击方法监听
- (void)changeIcon:(UIGestureRecognizer *)gesture
{
    [self.delegate headerCellChangeIcon:self];
}


@end
